package top.songxs.gmall.product.rpc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.common.result.ResultCodeEnum;
import top.songxs.gmall.product.rpc.biz.CategoryFeignRpcService;
import top.songxs.gmall.product.view.CategoryView;
import top.songxs.gmall.product.vo.CategoryVo;

import java.util.List;

@RestController
@RequestMapping("api/inner/product")
public class CategoryFeignRpcController {

    @Autowired
    private CategoryFeignRpcService categoryFeignRpcService;
    @GetMapping("/categorys/tree")
    public Result<List<CategoryVo>> findAllCategoryTree() {
        List<CategoryVo> list = categoryFeignRpcService.findAllCategoryTree();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/category3List/{skuId}")
    public Result<CategoryView> findAllCategory(@PathVariable("skuId") Long skuId) {
        CategoryView categoryView = categoryFeignRpcService.findAllCategory(skuId);
        return Result.build(categoryView, ResultCodeEnum.SUCCESS);
    }



}
